#encoding:utf-8
from functools import wraps
from flask import session,redirect,url_for
#装饰器

#装饰器,相当于方法替换
def login_requisite(func):

    @wraps(func)
    def wrapper(*args,**kwargs):
        if session.get('user_id'):
            return func(*args,**kwargs)
        else:
            return redirect(url_for('login'))
    return wrapper
